$(document).ready(function(e){
	var userId;
	mui.plusReady(function() {
		userId = plus.navigator.getCookie( "id");
		// 查询商品类型列表
		$.ajax({
			url:backend_url + "/is/imc.action",
			data:{
				"userId":userId
			},
			type:"POST",
			dataType:"json",
			success:function(data){
				$("#product_list").empty();
				var page_list = data.b;
				// console.log(page_list);
				for(var i = 0 ; i< page_list.length;i++){
					var issueTypeid = page_list[i].issueTypeid;
					var issueType = judge_issueType(issueTypeid);
					var imgLocation = page_list[i].imageLocation;
					var images = "";
					if(imgLocation != null && imgLocation.length != 0){
						images = imgLocation.split(";");
					}
					var li = `<li class="product_li" id=`+page_list[i].id+`>
								<a href="javascript:;">`;
					if(images.length>1){
						// console.log(images[0].substring(2));
						li +=  `<img class="mui-pull-left" src=`+img_url+images[0].substring(2)+` onerror="this.onerror='';src='../images/error_img.png' " alt="产品图片">`;
					}else {
						// 单张图
						li += `<img class="mui-pull-left" src=`+img_url+images+` onerror="this.onerror='';src='../images/error_img.png' " alt="产品图片">`;
					}
					li +=  `<div>
								<p class="title">`+page_list[i].issueTitle+`</p>
								<p class="issueType"><small>[</small><span>`+issueType+`</span><small>]</small></p>
							</div>
						</a>
					</li>`;
					// console.log(li);
					$("#product_list").append(li);
				}
			},
			error:function(er){
				// console.log(er);
				alert("呃。。网络似乎除了什么问题，请检查网络连接或重试！");
				//window.location.reload();
			}
		});
	});
});
// 通过issueTypeid判断issueType
function judge_issueType(issueTypeid){
	var issueType;
	if(issueTypeid == 1){
		issueType = "金属制品";
	}else if(issueTypeid == 2){
		issueType = "纸制品";
	}else if(issueTypeid == 3){
		issueType = "电子产品";
	}else if(issueTypeid == 4){
		issueType = "塑胶制品";
	}else{
		issueType = "木制品";
	}
	return issueType;
}